/* 
 * $Id: Condition.cc,v 1.3 2006-04-03 10:40:26 bacon Exp $
 */

#include <xpp/bas/Condition.h>

namespace xpp
{
	namespace bas
	{

		Condition::Condition () 
		{
			if (xp_cond_open(this) == XP_NULL) {
				XPP_THROW (ConditionException);
			}
		}

		Condition::~Condition ()
		{
			xp_cond_close (this);
		}

		void Condition::signal () 
		{
			xp_cond_signal (this);
		}

		void Condition::broadcast () 
		{
			xp_cond_broadcast (this);
		}

		void Condition::wait (const Mutex& mutex) 
		{
			xp_cond_wait (this, &(Mutex&)mutex);
		}

		void Condition::wait (const Mutex& mutex, xp_time_t timeout) 
		{
			xp_cond_twait (this, &(Mutex&)mutex, timeout);
		}

	}
}
